package com.xzsoft.gdwz.common;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.joda.time.DateTime;

import com.xzsoft.gdwz.HttpInterfaces.JingDongInf;


public class ScheduledTask {
	private JingDongInf jdi;
	public static void main(String[] args) {
		ScheduledTask st = new ScheduledTask();
		st.scheduale();
	}
	
	public void scheduale(){
		Runnable runnable = new Runnable() {
		      public void run() {
		    	  try {
					//jdi.getToken();
				} catch (Exception e) {
					e.printStackTrace();
				}
		      }
		    };
		    DateTime dateTime = new DateTime();
			DateTime dateTime1 = dateTime.plusMinutes(1);
			dateTime1 = new DateTime(Integer.parseInt(dateTime1.toString("yyyy")),Integer.parseInt(dateTime1.toString("MM")),Integer.parseInt(dateTime1.toString("dd")),Integer.parseInt(dateTime1.toString("HH")),Integer.parseInt(dateTime1.toString("mm")),0);
			System.out.println("dateTime:"+dateTime.toString("yyyy-MM-dd HH:mm:ss"));
			System.out.println("dateTime1:"+dateTime1.toString("yyyy-MM-dd HH:mm:ss"));			
			int delay = dateTime1.getSecondOfDay()-dateTime.getSecondOfDay();
			System.out.println(delay);
		    ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
		    service.scheduleAtFixedRate(runnable, delay, 60, TimeUnit.SECONDS);
	}
}
